package emergency;

public class StateInProgress extends State{

	/**
	 * Method for cancelling the given emergency
	 * 
	 * @post units of the given emergency are revoked
	 * 
	 * @post the state is set to canceled
	 */
	@Override
	public void cancel(Emergency e) throws IllegalStateException {
		e.revokeUnits(); // task of the units is done 
		e.setState(new StateCanceled());
	}

	/**
	 * Method for competing the given emergency
	 * 
	 * @post units of the given emergency are revoked
	 * 
	 * @post the state is set to completed
	 */
	@Override
	public void complete(Emergency e) throws IllegalStateException {
		e.revokeUnits(); // task of the units is done
		e.setState(new StateCompleted());
	}

	/**
	 * Method for sending units to the given emergency
	 * 
	 * @throws IllegalStateException, can't send units in inProgress state 
	 */
	@Override
	public void sendUnits(Emergency e) throws IllegalStateException {
		throw new IllegalStateException("The emergency at place " + e.getLocation().toString() + " is in progress, units already send");	
	}

	/**
	 * Method for getting a string representation of this concrete state
	 * 
	 * @return Returns a string representation of this concrete state
	 */
	@Override
	public String toString() {
		return("stateinprogress");
	}
}
